﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace HelloWPF.RouteEvent
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class RouteEventWindow : Window
    {
        public RouteEventWindow()
        {
            InitializeComponent();
        }
        #region Button冒泡事件，由内到外
        /// <summary>
        /// 路由事件监听了
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Grid_Click(object sender, RoutedEventArgs e)
        {
            Debug.WriteLine("Grid_Click");
        }

        /// <summary>
        /// 路由事件监听了
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StackPanel_Click(object sender, RoutedEventArgs e)
        {
            Debug.WriteLine("StackPanel_Click");
        }

        /// <summary>
        /// 路由事件监听了
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Debug.WriteLine("Button_Click");
            //e.Handled = true;
        }
        #endregion


        #region Border冒泡事件，由内到外
        /// <summary>
        /// 路由事件监听了
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StackPanel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Debug.WriteLine("Border_StackPanel_MouseLeftButtonDown");
        }

        /// <summary>
        /// 路由事件监听了
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Debug.WriteLine("Border_MouseLeftButtonDown");
            //选择消息系统，消息至此结束，后面不用处理，消息还是继续传递
            //e.Handled = true;
        }
        #endregion

        #region Border隧道事件，由外到内
        /// <summary>
        /// 路由事件监听了
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StackPanel_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Debug.WriteLine("StackPanel_PreviewMouseLeftButtonDown");
            //e.Handled = true;
        }
        #endregion



        private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            //this.DragMove();
        }



    }
}
